# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-sys-uname
pkgver=1.2.3
pkgrel=1
pkgdesc='An interface for gathering information about your current platform'
arch=(any)
url='https://github.com/djberg96/sys-uname'
license=(Apache)
depends=(ruby-ffi)
makedepends=(ruby-rspec ruby-rake)
checkdepends=(ruby-rubocop)
options=(!emptydirs)
source=(https://github.com/djberg96/sys-uname/archive/sys-uname-$pkgver.tar.gz)
sha256sums=('6a17f1708def7dce959a6b6e788e7078b2fde74a6a4aafbf8a8ef663fcc9a520')

prepare() {
  cd sys-uname-sys-uname-$pkgver
  sed -r 's|~>|>=|g' -i sys-uname.gemspec
}

build() {
  local _gemdir="$(gem env gemdir)"
  cd sys-uname-sys-uname-$pkgver
  gem build sys-uname.gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    sys-uname-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd sys-uname-sys-uname-$pkgver
  GEM_HOME="tmp_install/$_gemdir" rake
}

package() {
  cd sys-uname-sys-uname-$pkgver
  cp -a tmp_install/* "$pkgdir"/
}
